package com.easyim.imclient.client;

import com.easyim.imclient.config.ClientProperties;
import jakarta.annotation.PostConstruct;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class ClientInit {

    @Autowired
    ClientProperties clientProperties;

    @PostConstruct
    public void init() {
        for (Integer i = 0; i < clientProperties.getClientThreadCount(); i++) {
            SingleThreadClient singleThreadClient = new SingleThreadClient();
            singleThreadClient.setIndex(i);
            singleThreadClient.setClientProperties(clientProperties);
            Thread nettyThread = new Thread(singleThreadClient, "tcpClientThread");
            nettyThread.start();
        }
    }
}
